1. Start with pixel clusters from FlowSOM (Gaussian blur sigma=2, divide by total to get frequencies before FlowSOM).
  2. For each point, for each pixel, look at all neighboring pixels with a radius of 2, i.e. 5x5 kernel around the center pixel. Count the number of each cluster type, then divide by total number of pixels in kernel to get the frequency of each pixel cluster in the kernel (total number of pixels is not always 24 because of edges and empty pixels that didn’t get an assignment).
  3. For each pair of clusters i and j, randomly sample the number of pixels to total number of pixels in the smaller cluster. Calculate the enrichment of cluster j near cluster i divided by the enrichment of cluster i near itself.
  4. Average across all points.

1 Pixel clusters x marker

2 Breakdown of FlowSOM clusters

## 
##      1      2      3      4      5      6      7      8      9     10     11 
##   3206  25447 216480 270955 133636 151544 177754 213545 153145 111552  89981 
##     12     13     14     15     16     17     18     19     20     21     22 
##  61881 257673 250227 144962 117084 293753  89282 301555 125397  71071  91084 
##     23     24     25     26     27     28     29     30     31     32     33 
## 243798  68038 207261 100549 207274 146033 185281 126683  80805 222667 233569 
##     34     35     36     37     38     39     40     41     42     43     44 
## 303244  56319 154437 291295 286847 220917 131085  54658  72257  45004 141708 
##     45     46     47     48     49     50     51     52     53     54     55 
## 118070  31823  90095  30211  19230 193299  47275 103269 138929  48023 158978 
##     56     57     58     59     60     61     62     63     64     65     66 
##   3048 108933    336 272720 288357 224024 124311  71103  11021  81978   7689 
##     67     68     69     70     71     72     73     74     75     76     77 
##  54301   3676 215533  11260  21504  27745 111142  54258  22843  33204 200482 
##     78     79     80     81     82     83     84     85     86     87     88 
## 158782  21723 108811 167448  69528 110483  53159 169367   4592 121523 108609 
##     89     90     91     92     93     94     95     96     97     98     99 
## 172065 289296 347320 123071  97964  84054   2455  84036  27566  63666 128493 
##    100 
## 142124

3 All points

3.1 Plot with range 0-1

## [1] "Ratios that are greater than 1"
## [1] "c56, clust_46: 2.51744762506982"
## [1] "c67, clust_46: 1.10296256073852"

3.2 Plot with range 0-0.5

3.3 Plot with range 0-95th percentile

4 Histogram of scores

5 All points, zscore

6 Each point separately